using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RevivalPoint : MonoBehaviour
{
    private RevivalManager revivalManager;
    private bool isTrigger;
    void Start()
    {
        revivalManager = RevivalManager.instance;
    }

    void Update()
    {
        if (Input.GetKeyUp(KeyCode.E) && isTrigger)
        {
            PlayerDataManger.instance.setRevivalPoint(transform.position);
            revivalManager.refresh();
        }
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag(Tags.Player))
            isTrigger = true;
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag(Tags.Player))
            isTrigger = false;
    }
}
